 /**
   * Copyright 2014 Viettel Telecom. All rights reserved.
   * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
   */
 package com.viettel.core.bussiness.cms; 
import java.util.List; 

import org.springframework.beans.factory.annotation.Autowired; 

import com.viettel.core.exceptions.BusinessException; 
import com.viettel.core.exceptions.DataAccessException; 
import com.viettel.core.dao.cms.MediaDAO;
import com.viettel.core.entities.cms.Media;
import com.viettel.core.entities.vo.MediaSearchFilter;
import com.viettel.core.entities.vo.MediaSearchVO;
 /**
   *  Mo ta muc dich cua lop (interface)
   *  @author: TOANTM1
   *  @version:  
   *  @since: 27/02/2014 - 11:34:02
   */
 public class MediaMgrImpl implements MediaMgr{ 
	@Autowired 
	MediaDAO mediaDAO; 
 
 	/**@author TOANTM1
  	 * 27/02/2014 - 11:34:02
  	 * For: 
  	 * @description: 
  	 */
 	@Override 
	public Media getMediaById(Integer id) throws BusinessException { 
		try { 
			return  mediaDAO.getMediaById(id); 
		} catch (DataAccessException e) { 
			throw new BusinessException(e); 
		} 
	} 
 
 	/**@author TOANTM1
  	 * 27/02/2014 - 11:34:02
  	 * For: 
  	 * @description: 
  	 */
 	@Override 
	public Media createMedia(Media media) throws BusinessException { 
		try { 
			return mediaDAO.createMedia(media); 
		} catch (DataAccessException e) { 
			throw new BusinessException(e); 
		} 
	} 
 
 	/**@author TOANTM1
  	 * 27/02/2014 - 11:34:02
  	 * For: 
  	 * @description: 
  	 */
 	@Override 
	public void updateMedia(Media media) throws BusinessException { 
		try { 
			mediaDAO.updateMedia(media); 
		} catch (DataAccessException e) {	 
			throw new BusinessException(e); 
		} 
	} 
 
 	/**@author TOANTM1
  	 * 27/02/2014 - 11:34:02
  	 * For: 
  	 * @description: 
  	 */
 	@Override 
	public void deleteMedia(Media media) throws BusinessException { 
		try { 
			mediaDAO.deleteMedia(media); 
		} catch (DataAccessException e) { 
			throw new BusinessException(e); 
		} 
	}

	@Override
	public List<MediaSearchVO> getListMediaByFilter(MediaSearchFilter filter)
			throws BusinessException {
		try { 
			return mediaDAO.getListMediaByFilter(filter); 
		} catch (DataAccessException e) { 
			throw new BusinessException(e); 
		} 
	}

	@Override
	public List<Media> getAllMedias() throws BusinessException {
		try {
			return mediaDAO.getAllMedias();
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}
	@Override
	public List<Media> getListMediasByCmsUserId(Integer id) throws BusinessException{
		try {
			return mediaDAO.getListMediasByCmsUserId(id);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}
	@Override
	public Boolean checkNameExist(String userName) throws BusinessException{
		try {
			return mediaDAO.checkNameExist(userName);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}
	@Override
	public Boolean checkCodeExist(String userName) throws BusinessException{
		try {
			return mediaDAO.checkCodeExist(userName);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}
	@Override
	public Integer getIdFromName(String userName) throws BusinessException{
		try {
			return mediaDAO.getIdFromName(userName);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}
	@Override
	public Media getMediaFromName(String userName) throws BusinessException{
		try {
			return mediaDAO.getMediaFromName(userName);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}
} 
